﻿using WindowsGame1;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
using WindowsGame1.Extensions;
using System.Collections.Generic;

namespace TestProject1
{


    /// <summary>
    ///This is a test class for RectDungeonTest and is intended
    ///to contain all RectDungeonTest Unit Tests
    ///</summary>
    [TestClass()]
    public class RectDungeonTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for RectDungeon Constructor
        ///</summary>
        [TestMethod()]
        [DeploymentItem("WindowsGame1.exe")]
        public void RectDungeonConstructorTest()
        {
            int seed = 0;
            int top = 0;
            int left = 0;
            int height = 60;
            int width = 120;
            var target = new RectDungeon(seed, top, left, height, width);
            target.generateDungeon();
            Debug.WriteLine(target.ToString());
        }
        /// <summary>
        ///A test for RectDungeon Constructor
        ///</summary>
        [TestMethod()]
        [DeploymentItem("WindowsGame1.exe")]
        public void RectDungeonConstructorsTest()
        {
            int seed = 0;
            var rnd = new Random(seed);
            int top = 0;
            int left = 0;
            int height = 60;
            int width = 120;
            var rects = new List<RectDungeon>();
            var root = new RectDungeon(seed, top, left, height, width);
            rects.Add(root);
            while(rects.Count<22)
            {
                int splitIdx = rnd.NextI(rects.Count-1);
                RectDungeon toSplit = rects[splitIdx];
                if(toSplit.split())
                {
                    rects.Add(toSplit.LeftChild);
                    rects.Add(toSplit.RightChild);
                }
            }
            root.generateDungeon();
            Debug.WriteLine("Starting output");
            RectDungeon.PrintDungeons(rects,s=>Debug.Write(s),()=>Debug.WriteLine(string.Empty));
            Debug.WriteLine("Finished output");
        }



        /// <summary>
        ///A test for split
        ///</summary>
        [TestMethod()]
        [DeploymentItem("WindowsGame1.exe")]
        public void splitTest()
        {
            PrivateObject param0 = null; // TODO: Initialize to an appropriate value
            RectDungeon_Accessor target = new RectDungeon_Accessor(param0); // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = target.split();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
